
#include <stdint.h>

#define SCREEN_XSIZE 320
#define SCREEN_YSIZE 480

#define R61581_VFP 0
#define R61581_VBP 0
#define R61581_DPL 0
#define R61581_EPL 0
#define R61581_HSPL 0
#define R61581_VSPL 0

#if 0
uint8_t cmd_B0[] = {0xB0, 0x00};
uint8_t cmd_B3[] = {0xB3, 0x02, 0x00, 0x00, 0x10};
uint8_t cmd_B4[] = {0xB4, 0x00};
uint8_t cmd_B9[] = {0xB9, 0x01, 0xFF, 0xFF, 0x18};
uint8_t cmd_C0[] = {0xC0, 0x02, 0x3B, 0x00, 0x00, 0x00, 0x01, 0x00, 0x43};             /*Panel Driving Setting*/
uint8_t cmd_C1[] = {0xC1, 0x08, 0x15, R61581_VFP, R61581_VBP};                         /*Display Timing Setting for Normal Mode */
uint8_t cmd_C4[] = {0xC4, 0x15, 0x03, 0x03, 0x01};                                     /*Source/VCOM/Gate Driving Timing Setting*/
uint8_t cmd_C6[] = {0xC6, 0x00};                                                       /*Interface Setting*/
uint8_t cmd_C8[] = {0xC8, 0x0c, 0x05, 0x0A, 0x6B, 0x04, 0x06, 0x15, 0x10, 0x00, 0x31}; /*Gamma Set*/
uint8_t cmd_0C[] = {0x0C, 0x55};
uint8_t cmd_3A[] = {0x3A, 0x55};
uint8_t cmd_38[] = {0x38};
uint8_t cmd_D0[] = {0xD0, 0x07, 0x07, 0x14, 0xA2};
uint8_t cmd_D1[] = {0xD1, 0x03, 0x5A, 0x10};
uint8_t cmd_D2[] = {0xD2, 0x03, 0x04, 0x04};
// R61581_ORI == 0
// uint8_t cmd_36[] = {0x36, 0xE0};
// uint8_t cmd_36[] = {0x36, 0x20};

#else

uint8_t cmd_B0[] = {0xB0, 0x00};
uint8_t cmd_B3[] = {0xB3, 0x02, 0x00, 0x00, 0x00};
uint8_t cmd_C0[] = {0xC0, 0x13, 0x3B, 0x00, 0x02, 0x00, 0x01, 0x00, 0x43};
uint8_t cmd_C1[] = {0xC1, 0x08, 0x16, 0x08, 0x08};
uint8_t cmd_C4[] = {0xC4, 0x11, 0x07, 0x03, 0x03};
uint8_t cmd_C6[] = {0xC6, 0x00};
uint8_t cmd_C8[] = {0xC8, 0x03, 0x03, 0x13, 0x5C, 0x03, 0x07, 0x14, 0x08, 0x00, 0x21, 0x08, 0x14, 0x07, 0x53, 0x0C, 0x13, 0x03, 0x03, 0x21, 0x00};
uint8_t cmd_0C[] = {0x0C, 0x55};
uint8_t cmd_38[] = {0x38};
uint8_t cmd_3A[] = {0x3A, 0x55};
uint8_t cmd_D0[] = {0xD0, 0x07, 0x07, 0x1D, 0x03};
uint8_t cmd_D1[] = {0xD1, 0x03, 0x30, 0x10};
uint8_t cmd_D2[] = {0xD2, 0x03, 0x14, 0x04};
#endif

uint8_t cmd_11[] = {0x11};
// sleep_ms(10};
uint8_t cmd_2A[] = {0x2A, 0x00, 0x00, ((SCREEN_XSIZE - 1) >> 8) & 0XFF, (SCREEN_XSIZE - 1) & 0XFF};
uint8_t cmd_2B[] = {0x2B, 0x00, 0x00, ((SCREEN_YSIZE - 1) >> 8) & 0XFF, (SCREEN_YSIZE - 1) & 0XFF};
// sleep_ms(10};
uint8_t cmd_29[] = {0x29};
// sleep_ms(5};
uint8_t cmd_2C[] = {0x2C};
// sleep_ms(5};